package com.tutu.controller.backend;

import com.tutu.common.DataTableFactory;
import com.tutu.controller.common.CommonController;
import com.tutu.service.LogInfoService;
import com.tutu.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 日志管理
 */
@Controller
@RequestMapping(value = "backend/logInfo")
public class LogInfoController extends CommonController {

    @Autowired
    LogInfoService logInfoService;

    @RequestMapping(value = "/index")
    public String index() {
        return "backend/logInfo/list";
    }

    @RequestMapping("/list")
    public void list(HttpServletResponse response, String keyWord, Integer draw, Integer start, Integer length) {
        int pageNum = getPageNum(start, length);

        Map<String, Object> result = DataTableFactory.fitting(draw, logInfoService.pageByParams(keyWord, pageNum, length));

        WebUtil.printJson(response, result);
    }
}
